#!/usr/bin/env bash

# 早于4.0的bash，对于case语法绝不能匹配多个测试条件
# ;;& 表达式终止运行；允许case语句继续执行下一条测试

read -n 1 -p "Type a character> "
echo
case $REPLY in
	[[:upper:]]) echo "'$REPLY' is upper case." ;;&
	[[:lower:]]) echo "'$REPLY' is lower case." ;;&
	[[:alpha:]]) echo "'$REPLY' is alphabetic." ;;&
	[[:digit:]]) echo "'$REPLY' is digit case." ;;&
	[[:graph:]]) echo "'$REPLY' is visible character." ;;&
# punctuation symbol 标点符号
	[[:punct:]]) echo "'$REPLY' is punctuation symbol." ;;&
	[[:space:]]) echo "'$REPLY' is whitespace character." ;;&
	[[:xdigit:]]) echo "'$REPLY' is hexadecimal digit." ;;&
esac
